<template>
  <div class="wrapper">
    <transition :name="transitionName">
      <router-view :class="{'child-view': isTransition}"></router-view>
    </transition>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        transitionName: 'slide-left',
        isTransition: true
      }
    },
    beforeRouteUpdate (to, from, next) {
      // console.log(to)
      let isBack = this.$router.isBack
      if (isBack) {
        this.transitionName = 'slide-right'
      } else {
        if(to.path=='/a'||to.path=='/b'||to.path=='/c' ||to.path=='/d' ){
          this.isTransition = false
          this.transitionName = 'noTransition'
        }else{
          this.isTransition = true
          this.transitionName = 'slide-left'
        }
      }
      this.$router.isBack = false
      setTimeout(() => {
        next()
      }, 60)
    }
  }
</script>

<style scoped>
  .wrapper{
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    overflow: hidden!important;
  }
 .child-view {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transition: all .5s cubic-bezier(.55,0,.1,1);
}
.slide-left-enter, .slide-right-leave-active {
  opacity: 0;
  -webkit-transform: translate(100px, 0);
  transform: translate(100px, 0);
}
.slide-left-leave-active, .slide-right-enter {
  opacity: 0;
  -webkit-transform: translate(-100px, 0);
  transform: translate(-100px, 0);
}
 
</style>
